<%@page import="org.upt.dcda.presentation.TagInformationExtended"%>
<%@page import="org.upt.dcda.presentation.AuthorInformation"%>
<%@page import="org.upt.dcda.presentation.SessionAttributes"%>
<%@page import="org.upt.dcda.db.UserEntity"%>
<%@page import="org.upt.dcda.db.AuthorEntity"%>
<%@page import="org.upt.dcda.db.TagEntity"%>
<%@page import="java.util.List"%>
<%@ taglib prefix="stripes"
	uri="http://stripes.sourceforge.net/stripes.tld"%>
<%
if (!SessionAttributes.isAdmin(request))
{
	response.sendRedirect("index.jsp");
}
else
{
%>
<stripes:layout-render name="layout/default.jsp"
	pageTitle="Using A Layout">

	<stripes:layout-component name="pageTitle">
	Admin page
 	</stripes:layout-component>

	<stripes:layout-component name="html_head">

	</stripes:layout-component>

	<stripes:layout-component name="contents">
		<%
						AuthorInformation authorInfo = new AuthorInformation();
						List<AuthorEntity> authors = authorInfo.getAllAuthors(request, response);
						TagInformationExtended tagInfo = new TagInformationExtended();
						List<TagEntity> tags = tagInfo.getAllTags(request, response);
		%>
		<form action="addnewbook" method="post">
			Title: <input type="text" name="title"><br> Description:
			<input type="text" name="description"><br> Price: <input
				type="text" name="price"><br> Quantity: <input
				type="text" name="quantity"><br> Author: <select
				name="authorId">
				<%
					for (AuthorEntity ae : authors)
								{
				%>
				<option value="<%=ae.getAuthorId()%>"><%=ae.getAuthorName()%></option>
				<%
					}
				%>
			</select> Tags:
			<%
				for (TagEntity te : tags)
							{
			%>
			<input type="checkbox" name="tags" value="<%=te.getTagId()%>" />
			<%=te.getTagName()%><br />
			<%
				}
			%>

			<input type=submit value="Add">
		</form>
		
	</stripes:layout-component>

</stripes:layout-render>
<%
}
%>